{include file="public/header"}
<body>
	<div class="sectionY">
		<a href="javascript:history.back();">
			<img src="__PUBLIC__/home/images/a19.png" alt="" class="a1">
		</a>
		<p class="p1">上传截图</p>
	</div>
	<div class="kong1" style=""></div>
	<div class="shang_section1">
		<div class="container">
			<div class="title">
				<p class="p1">支付成功，请上传截图</p>
			</div>
			<div class="center">
				<form action="" method="post" enctype="multipart/form-data">
					<div class="f1">
						<img src="{$pay_img|default='__PUBLIC__/home/images/a42.png'}" alt="" id="imghead" >
						<!-- <img src="images/a43.png" alt=""> -->
					</div>
					<div class="f1">
						<input class="pic_btn" type="button" value="上传">
					</div>
					<input type="file" id="file" onchange="imgChange(this);" style="height: 0px;width: 0px;" />
				</form>
			</div>
		</div>
	</div>
</body>
<script>
	var is_app=0,order_id={$order_id};
	try {
		is_app = android.getType();
	}catch (e) {
		
	}
	$(function(){
		$(".pic_btn").click(function(){
			if(is_app==1){
				android.uploadImage(location.origin+"/home/Upload/index.html");
			}else{
				$(this).parent().siblings("input").click();
			}
		});
	})
</script>
<script type="text/javascript">
	//安卓回调
	function setImage(img_url) {
		$("#imghead").attr('src',img_url); // 修改img标签src属性值
		$.post("{:url('setOrderPayImg')}", {order_id:order_id, img_url:img_url},function (res) {
			modal.msg(res.result_info);
			setTimeout(function () {
				location.href="{:url('Index/index')}";
			}, 666);

		});
	}
	function imgChange(obj) {
		var docObj=$(obj).get(0);
		if (docObj.files && docObj.files[0]) {
			if(!/image\/\w+/.test(docObj.files[0].type)){
				//图片文件的type值为image/png或image/jpg
				layer.msg("文件必须为图片！");
				return false;
			}
			var formData = new FormData();
			formData.append("image",docObj.files[0]);
			$.ajax({
				url: "{:url('Upload/index')}",
				type: "POST",
				data: formData,
				/**
				 *必须false才会自动加上正确的Content-Type
				 */
				contentType: false,
				/**
				 * 必须false才会避开jQuery对 formdata 的默认处理
				 * XMLHttpRequest会对 formdata 进行正确的处理
				 */
				processData: false,
				success: function (rs) {
					if(rs.result_code=='0000'&&rs.result_data!=''){
						$("#image_url").val(rs.result_data);
						$("#imghead").attr('src',rs.result_data);
						setImage(rs.result_data);
					}else{
						layer.msg('图片有误请更换图片');
					}
				},
				error: function () {
					layer.msg('system error');
				}
			});
		} else {
			layer.msg('请上传图片');
		}
		return true;
	}
</script>
</html>